using System;
using System.Collections.Generic;
using System.Text;

using System.Data;
using System.Data.Common;
using Husb.Data;
using Husb.DataUtil;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using CentralOffice.MyTable.Data;

using DiaryTable = CentralOffice.MyTable.Data.DiaryDataSet.diaryDataTable;
using DiaryRow = CentralOffice.MyTable.Data.DiaryDataSet.diaryRow;
namespace CentralOffice.MyTable.DataAccess
{
    public class DiaryAdapter : DataAccessAdapter<MyTable.Data.DiaryDataSet, DiaryTable, DiaryRow>
    {
        public DiaryAdapter()
        {
            this.TableName = "diary";
            DeleteStoredProc = "Diary_DeleteDiary";

            GetAllStoredProc = "Diary_SelectDiaryAll";
            InsertStoredProc = "Diary_InsertDiary";
            UpdateStoredProc = "Diary_UpdateDiary";
            FindStoredProc = "Diary_SelectDiaryDynamic";
            GetByIdStoredProc = "Diary_SelectDiary";
            GetPagedStoredProc = "Diary_SelectDiaryPaged";
            GetRowCountStoredProc = "Diary_SelectDiaryRowCount";
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
            db.AddInParameter(cmd, "UserId", DbType.AnsiString, "UserId", DataRowVersion.Current);
            db.AddInParameter(cmd, "UserName", DbType.AnsiString, "UserName", DataRowVersion.Current);
            db.AddInParameter(cmd, "DiaDate", DbType.DateTime, "DiaDate", DataRowVersion.Current);
            db.AddInParameter(cmd, "DiaType", DbType.AnsiString, "DiaType", DataRowVersion.Current);
            db.AddInParameter(cmd, "Subject", DbType.String, "Subject", DataRowVersion.Current);
            db.AddInParameter(cmd, "DiaContent", DbType.String, "DiaContent", DataRowVersion.Current);
            db.AddInParameter(cmd, "AttachMentSize", DbType.AnsiString, "AttachMentSize", DataRowVersion.Current);
            db.AddInParameter(cmd, "AttachMentName", DbType.String, "AttachMentName", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastEditDate", DbType.DateTime, "LastEditDate", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastCommentTime", DbType.DateTime, "LastCommentTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "ToId", DbType.AnsiString, "ToId", DataRowVersion.Current);
            db.AddInParameter(cmd, "ToName", DbType.String, "ToName", DataRowVersion.Current);
            db.AddInParameter(cmd, "DeleteFlag", DbType.AnsiString, "DeleteFlag", DataRowVersion.Current);
        }
    }
}
